from bs4 import BeautifulSoup

file_path = 'qh_data.html'
with open(file_path, 'r', encoding='gbk') as f:
    soup = BeautifulSoup(f.read(), 'html.parser')
    tables = soup.find_all("table")
    res_tables = []
    for table in tables:
        all_tr = table.find_all("tr")
        all_tr.pop(0)
        res_table =[]
        for tr in all_tr:
            all_td = tr.find_all('td')
            res_td = []
            for td in all_td:
                if td.get_text().find('本日合计') == -1 and td.get_text().find('上榜单元') == -1:
                    res_td.append(td.get_text().replace("\xa0", ""))
            if len(res_td)>0:
                res_table.append(res_td)
        res_tables.append(res_table)
    for res in res_tables:
        print(res)

